home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Celestin Apprentice 7
/
Apprentice-Release7.iso
/
Source Code
/
Pascal
/
System
/
Sample Init
/
Sample without A4
/
Sample.p
next >
Wrap
Text File
|
1997-02-01
|
2KB
|
102 lines
unit Init;
interface
{$MAIN}
procedure Main;
implementation
uses
Traps, Types, Files, Events, OSUtils, Resources, Memory, Processes, GestaltEqu, Traps, SegLoad, LowMem;
type
ProcPtrPtr = ^ProcPtr;
const
CurAppNameAddr = $910;
FinderNameAddr = $2E0;
const
HelperStateGestalt = 'AsiX';
HS_Booting = 1;
HS_Normal = 2;
procedure SpaceForOSDispatchOldAddr;
begin
end;
procedure SpaceForInitMenusOldAddr;
begin
end;
procedure SpaceForHelperState;
begin
end;
function AssimilatorHelperGestalt (selector: OSType; var response: longInt): OSErr;
var
SpaceForHelperStatePtr: LongIntPtr;
begin
{$unused(selector)}
SpaceForHelperStatePtr := LongIntPtr(@SpaceForHelperState);
response := SpaceForHelperStatePtr^;
AssimilatorHelperGestalt := noErr;
end;
procedure AssimilatorHelperOSDispatchPatch; asm;
begin
{ check for the PostHighLevelEvent selector }
cmpi.w #$34, 4(sp)
bne.s continue
{ do stuff }
continue:
lea SpaceForOSDispatchOldAddr, a0
move.l (a0), a0
jmp (a0)
end;
procedure DoInitMenusPatch;
var
SpaceForHelperStatePtr: LongIntPtr;
SpaceForOSDispatchOldAddrPtr: ProcPtrPtr;
begin
SpaceForHelperStatePtr := LongIntPtr(@SpaceForHelperState);
if (SpaceForHelperStatePtr^ = HS_Booting) & (StringPtr(CurAppNameAddr)^ = StringPtr(FinderNameAddr)^) then begin
SpaceForHelperStatePtr^ := HS_Normal;
SpaceForOSDispatchOldAddrPtr := ProcPtrPtr(@SpaceForOSDispatchOldAddr);
SpaceForOSDispatchOldAddrPtr^ := ProcPtr(NGetTrapAddress(_OSDispatch, ToolTrap));
NSetTrapAddress(@AssimilatorHelperOSDispatchPatch, _OSDispatch, ToolTrap);
end;
end;
procedure AssimilatorHelperInitMenusPatch; asm;
begin
jsr DoInitMenusPatch
lea SpaceForInitMenusOldAddr, a0
move.l (a0), a0
jmp (a0)
end;
procedure Main;
var
junk: OSErr;
SpaceForHelperStatePtr: LongIntPtr;
SpaceForInitMenusOldAddrPtr: ProcPtrPtr;
begin
DetachResource(Get1Resource('INIT', 128));
SpaceForHelperStatePtr := LongIntPtr(@SpaceForHelperState);
SpaceForInitMenusOldAddrPtr := ProcPtrPtr(@SpaceForInitMenusOldAddr);
SpaceForHelperStatePtr^ := HS_Booting;
junk := NewGestalt( HelperStateGestalt, @AssimilatorHelperGestalt );
SpaceForInitMenusOldAddrPtr^ := ProcPtr(NGetTrapAddress(_InitMenus, ToolTrap));
NSetTrapAddress(@AssimilatorHelperInitMenusPatch, _InitMenus, ToolTrap);
end;
end.